home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8526 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: alpha.fdu.edu!rich
  2. From: "Mr. Rich Reybok" <rich@alpha.fdu.edu>
  3. Newsgroups: comp.lang.c
  4. Subject: Memcpy Problem
  5. Date: Mon, 4 Mar 1996 16:34:15 -0500
  6. Organization: Fairleigh Dickinson University
  7. Message-ID: <Pine.OSF.3.91.960304161419.15251A-100000@alpha.fdu.edu>
  8. NNTP-Posting-Host: alpha.fdu.edu
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11.  
  12. Hi.
  13.     I'm writing a little program using BC 4.5, and I seem to have run 
  14. into a bit of difficulty.
  15. Here's the code snippet:
  16.  
  17. {
  18. char *temp="2592000"   
  19. long l;
  20. char temp2[100];
  21. l=atol(temp)
  22. memcpy(temp2,(char *)(&l),sizeof(l));
  23. XXX(temp2,LONG_TYPE);
  24. }
  25.  
  26. where XXX is defined as XXX(void *value,int datatype);  XXX casts value 
  27. as datatype.  This code basically creates a long value out of a char * 
  28. that it's gets from elsewhere in the program.  It should then copy the 
  29. byte pattern of the long into a char * and send it to XXX.  However I get 
  30. a memory problem and the debugger exits with error 9. I don't know what 
  31. error 9 was,  couldn't find references to it anywhere :-(  If I change l 
  32. to an int and use atoi everything works fine.  However I have one value 
  33. that will always be a long so I need a solution.  Changing XXX is 
  34. impossible, it is in an SDK I'm using.  Any suggestions?  Am I 
  35. overlooking something between the long and int data types? 
  36.  
  37. TIA
  38. -Rich
  39.  
  40.  
  41. ********************************************************************************
  42. Rich Reybok
  43. Network & Systems Analyst
  44. Fairleigh Dickinson University
  45. 10 Woodridge Ave
  46. Hackensack, NJ 07601
  47. (201) 692-2357
  48. Reply: rich@fdu.edu
  49. *******************************************************************************
  50.  
  51.  
  52.